package compilers.AST.statement;

import compilers.AST.Node;
import compilers.AST.basics.Identifier;
import compilers.AST.expression.Expression;
import compilers.AST.types.TypeSpecifier;
import compilers.exceptions.SemanticalException;
import compilers.symbolTable.SymbolTableScope;

public class TypeDefStatement extends Statement {
	
	private TypeSpecifier fType;
	private Identifier fIdentifier;
	private boolean fArray;
	
	public TypeDefStatement(int lineNr) {
		super(lineNr);
		fArray = false;
	}
	
	public void print(int identLevel) {
		println(identLevel, "TypeDefStatement");
		fType.print(identLevel+1);
		if (fArray) {
			println(identLevel+1, "Array");
		}
		fIdentifier.print(identLevel+1);
	}
	
	public void checkSemantics(SymbolTableScope currentScope) throws SemanticalException {
		fType.checkSemantics(currentScope);
		fIdentifier.checkSemantics(currentScope);
	}
	
	public void setType(TypeSpecifier type) {
		fType = type;
	}
	
	public void setIdentifier(Identifier ident) {
		fIdentifier = ident;
	}
	
	public void makeArray() {
		fArray = true;
	}
}
